package com.hongxun.design.ui.dialogstyle;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.hongxun.design.R;
import com.hongxun.design.bean.SystemVersionBean;


/**
 * Created by ZerdoorDLPAPC on 2016/10/28.
 */
public class UpdateDialog extends Dialog {



    private View.OnClickListener confirmListener,dimssClick;
    private SystemVersionBean bean;

    public UpdateDialog(Context context, SystemVersionBean bean, View.OnClickListener confirmListener, View.OnClickListener dimssClick) {
        super(context, R.style.promoteDialogStyle);
        this.bean = bean;
        this.confirmListener = confirmListener;
        this.dimssClick = dimssClick;
        setContentView(R.layout.dialog_update);
        init();
    }

    private void init() {
        TextView appVersion = (TextView) findViewById(R.id.app_version_txt);
        appVersion.setText(bean.getVersion());
        TextView updateContent = (TextView) findViewById(R.id.app_update_content_txt);//更新内容
        updateContent.setText(bean.getContent());

        TextView protoCancleButton = (TextView) findViewById(R.id.promptbox_cancel);//取消
        TextView protoConfrirmButton = (TextView) findViewById(R.id.promptbox_confirm);//确定
        protoCancleButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dimssClick.onClick(v);
                dismiss();
            }
        });
        if (bean.getUpgrade()==0){
            protoCancleButton.setVisibility(View.VISIBLE);
        }else{
            protoCancleButton.setVisibility(View.GONE);
        }
        protoConfrirmButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmListener.onClick(v);
                if (bean.getUpgrade()==0){
                    dismiss();
                }
            }
        });
    }
}
